<template>
	<view>
		<van-cell-group inset>
			<van-field :value="editUser.currentValue" :label="editUser.editName"
				@change="editUser.currentValue = $event.detail" :placeholder="'请输入'+editUser.editName" />
		</van-cell-group>
		<div style="margin: 16px;">
			<van-button color="#fad556" round block type="primary" @click="send()">
				提交
			</van-button>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				editUser: {
					editKey: "",
					editName: "",
					currentValue: ""
				}
			}
		},
		onLoad(options) {
			this.editUser = JSON.parse(options.user);
		},
		methods: {
			send() {

				this.$request('/user/updateUser', {
					[this.editUser.editKey] : this.editUser.currentValue
				}, 'POST').then(res => {
					if(res){
						uni.navigateTo({
							url: './editUserMessage',
							success() {
								let page = getCurrentPages().pop();
							}
						})
					}
				})
			}
		}
	}
</script>

<style>
	page{
		/* background-color: #fad556; */
	}
</style>
